package com.example.networkinteraction.request.param;

import android.util.ArrayMap;
import android.util.Log;
import com.google.gson.Gson;
import okhttp3.RequestBody;

/**
 * Description:
 * File: RequestParam.java
 * Author: Administrator
 * Create: 2019/3/29 0029 下午 15:15
 */
public abstract class RequestParam {
    protected ArrayMap<String, Object> sArrayMap = new ArrayMap<>();

    public abstract RequestBody buildRequestBody();

    @Override
    public String toString() {
        return toJsonString();
    }

    public void addParam(String key, Object value) {
        sArrayMap.put(key, value);
    }

    protected String toJsonString() {
        String result = new Gson().toJson(sArrayMap);
        Log.d("junfutong", "toJsonString result " + result);
        return result;
    }
}
